package com.yiqi.liebang.feature.setting.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.suozhang.framework.framework.AM;
import com.suozhang.framework.framework.BaseActivity;
import com.yiqi.liebang.R;
import com.yiqi.liebang.entity.bo.UserCardBo;
import com.yiqi.liebang.entity.bo.UserCenterBo;
import com.yiqi.liebang.entity.bo.UserDataBo;
import com.yiqi.liebang.feature.mine.contract.UserContract;
import com.yiqi.liebang.feature.mine.dependencies.login.DaggerUserComponent;
import com.yiqi.liebang.feature.mine.dependencies.login.UserPresenterModule;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class AccountSecurityActivity extends BaseActivity implements  UserContract.View{

    @Inject
    UserContract.Presenter mPresenter;

    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.tv_user_phone)
    TextView mTvUserPhone;
    UserDataBo mUserDataBo;
    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_account_security;
    }


    @Override
    protected void initInjector() {
        DaggerUserComponent.builder().userPresenterModule(new UserPresenterModule(this)).build().inject(this);
    }

    @Override
    protected void initView() {
        initToolBar(mToolbar, "账号安全", true, true);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onStart() {
        super.onStart();
        mPresenter.getMineData();

    }

    @OnClick({R.id.btn_account_edit_phone, R.id.btn_account_edit_pwd})
    public void onViewClicked(View view) {

        switch (view.getId()) {

            case R.id.btn_account_edit_phone:
                Intent intent = new Intent(this, EditPhoneActivity.class);
                intent.putExtra("old_phone",mUserDataBo.getUserPhone());
                startActivity(intent);
                break;
            case R.id.btn_account_edit_pwd:
                Intent intents = new Intent(this, EditPwdActivity.class);
                intents.putExtra("old_phone",mUserDataBo.getUserPhone());
                startActivity(intents);
                break;
        }
    }


    @Override
    public void showUserCenterSuccess(UserCenterBo s) {

    }

    @Override
    public void showUserCenterError(String error) {

    }

    @Override
    public void showUserCardSuccess(UserCardBo s) {

    }

    @Override
    public void showMineSuccess(UserDataBo s) {
        mUserDataBo=s;
        mTvUserPhone.setText(TextUtils.isEmpty(s.getUserPhone())?"":s.getUserPhone().replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2"));
    }

    @Override
    public void showLikeSuccess() {

    }

    @Override
    public void showPrivateSuccess(Boolean error) {

    }

    @Override
    public void showUserEditSuccess() {

    }

    @Override
    public void showDeleteFriendSuccess() {

    }

    @Override
    public void showAddBlackSuccess() {

    }

    @Override
    public void showError(String error) {

    }
}
